<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Cadastro RDV</title>
	<link rel="stylesheet" type="text/css" href="css/tabela.css" />
</h:head>
<ui:composition template="/Menu.xhtml">
	<ui:define name="corpo">
		<h:body>
			<f:view encoding="ISO-8859-1">
				<h:form id="novaVisita">
					<h:messages layout="table" errorStyle="color: red"
						infoStyle="color: green" warnStyle="color: orange"
						fatalStyle="color: gray" showDetail="true" />
					<h4>Cadastrar</h4>
					<h:panelGrid columns="2">
						<h:outputText value="Nome Usuário" />
						<h:selectOneMenu style="width:300px"
							value="#{cadastroCicloRDV.usuario.login}"
							disabled="#{not login.usuario.admin or cadastroCicloRDV.iniciado}">
							<f:selectItems value="#{cadastroCicloRDV.usuarios}" var="u"
								itemLabel="#{u.nome}" itemValue="#{u.login}" />
						</h:selectOneMenu>
						<h:outputText value="RDV" />
						<h:selectOneMenu style="width:300px"
							value="#{cadastroCicloRDV.tipoId}"
							disabled="#{cadastroCicloRDV.iniciado}">
							<f:selectItems value="#{cadastroCicloRDV.tipos}" var="u"
								itemLabel="#{u.tipo}" itemValue="#{u.id}" />
						</h:selectOneMenu>
					</h:panelGrid>
					<br />
					<h:commandButton styleClass="g-button g-button-submit"
						action="#{cadastroCicloRDV.Consultar}" value="CONSULTAR"
						style="width:150px" />
					<h:commandButton styleClass="g-button g-button-submit"
						action="#{cadastroCicloRDV.novaConsulta}" value="LIMPAR"
						style="width:150px" />
					<br />
					<hr />
					<br />
					<br />
					<h:form
						rendered="#{login.usuario.admin and cadastroCicloRDV.iniciado}">
						<h:panelGrid columns="2">
							<h:outputText value="Status" />
							<h:selectOneMenu value="#{cadastroCicloRDV.cicloRDV.status}"
								style="width:300px">
								<f:selectItem itemValue="ENVIADO PARA CIFARMA" />
								<f:selectItem itemValue="RECEBIDO NA CIFARMA" />
								<f:selectItem itemValue="PROVISIONAMENTO REALIZADO" />
								<f:selectItem itemValue="PAGAMENTO EFETUADO" />
							</h:selectOneMenu>
							<h:outputText value="Data" />
							<p:calendar value="#{cadastroCicloRDV.cicloRDV.data}"
								id="popupCal" mode="inline" locale="pt">
								<p:ajax event="dateSelect"
									listener="#{cadastroCicloRDV.handleDateSelect}"
									update="txtData" />
							</p:calendar>
							<h:outputText value="Data Selecionada" />
							<h:inputText id="txtData" style="width:200px"
								value="#{cadastroCicloRDV.cicloRDV.data}" disabled="true">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:inputText>
							<h:outputText value="Observação" />
							<h:inputTextarea value="#{cadastroCicloRDV.cicloRDV.observacao}"
								style="width:300px" />
						</h:panelGrid>
						<br />
						<h:commandButton styleClass="g-button g-button-submit"
							action="#{cadastroCicloRDV.salvar}" value="SALVAR"
							style="width:150px" />
						<h:commandButton styleClass="g-button g-button-submit"
							action="#{cadastroCicloRDV.novo}" value="NOVO"
							style="width:150px" />
						<br />
						<hr />
						<br />
						<br />
					</h:form>
					<h:dataTable border="2" style="width:800px" styleClass="Tabela"
						value="#{cadastroCicloRDV.listaCicloRDV}" var="rdv"
						rendered="#{not empty cadastroCicloRDV.listaCicloRDV and cadastroCicloRDV.iniciado}">
						<h:column rendered="#{login.usuario.admin}">
							<f:facet name="header">
								<h:outputText value="Opções" />
							</f:facet>
							<h:commandButton value="EDITAR"
								styleClass="g-button g-button-submit"
								action="#{cadastroCicloRDV.editar}">
								<f:setPropertyActionListener
									target="#{cadastroCicloRDV.cicloRDV}" value="#{rdv}" />
							</h:commandButton>
							<h:commandButton value="EXCLUIR"
								action="#{cadastroCicloRDV.excluir}"
								styleClass="g-button g-button-red"
								onclick="return confirm('Confirma Exclusão do Ciclo RDV?');">
								<f:setPropertyActionListener
									target="#{cadastroCicloRDV.cicloRDV}" value="#{rdv}" />
							</h:commandButton>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Status" />
							</f:facet>
							<h:outputText value="#{rdv.status}" />
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Data" />
							</f:facet>
							<h:outputText value="#{rdv.data}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Observação" />
							</f:facet>
							<h:outputText value="#{rdv.observacao}" />
						</h:column>

					</h:dataTable>
				</h:form>
			</f:view>
		</h:body>
	</ui:define>
</ui:composition>
</html>